<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>挂靠公司授信信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<style type="text/css">
a:hover{
color:#3F48CE;
text-decoration:underline
}
</style>
<body class="iframeBody">
<div class="Wrapper">
<div id="pageInTab" class="pageInTab">
<div>
</div>
	 <form id="prj_lnk_comp_cr_lim_form">
                        <div class="fieldset1 tabel_col clearFix">
                       		 <div class="fieldBox col_100">
				                    <div class="label">挂靠公司名称</div>
				                    <div class="field">
				                          <a id="prjLnkCompNm" >${prjLnkCompNm}</a>
				                    </div>
		               		 </div>
		               		 
		               		  <div class="fieldBox col_50">
				                    <div class="label">当前实际敞口（元）</div>
				                    <div class="field">
				                          <span style="color: red" id="currCrAmt">${currCrAmt}</span>
				                    </div>
		               		 </div>
                        
		               		 <div class="fieldBox col_50">
				                    <div class="field">
				                           <div class="field">
						                          <input type="checkbox" id="isLimit" name="isLimit"  
						                         <c:if test="${crLimit.isLimit==1 }">
				                                 checked="checked"
				                                  </c:if>
						                          onchange="setCrAmtValue();" />取消敞口限制
				                    </div>
				                    </div>
		               		 </div>
		               		  <div class="fieldBox col_50">
                                <div class="label">开始时间</div>
                                <div class="field"> 
                              		<input name="startDt" id="startDt" type="text"   class="ui-datepicker"  value="${crLimit.startDt}"   validate="{required:true}">
                               		<span class="requiredSymbol" >*</span>
                                </div>
                            </div>
                              <div class="fieldBox col_50">
                                <div class="label">结束时间</div>
                                <div class="field"> 
                              		<input name="endDt"  id="endDt" type="text"  class="ui-datepicker"  value="${crLimit.endDt}"   validate="{required:true}">
                               		<span class="requiredSymbol" >*</span>
                                </div>
                            </div>
                              <div class="fieldBox col_50">
                                <div class="label">敞口金额（元）</div>
                                <div class="field"> 
                              		<input name="crAmt" id="crAmt"  class="ui-textbox"  type="text"    value="${crLimit.crAmt }"   validate="{required:true}">
                               		<span class="requiredSymbol" >*</span>
                                </div>
                            </div>
                             <div class="fieldBox col_100" style="display:none;">
								<div class="field">
								    <input name="crLimitId"  id="crLimitId" type="text" class="ui-textbox" value="${crLimit.id }" >
								    <input name="compId"  id="compId" type="text" class="ui-textbox" value="${crLimit.prjLnkCompId }" >
								</div>
							</div>
                            </div>
                           <div class="btnsBox">
				                <span id="prj_lnk_comp_add_btn_id" class="sq-button sq-button-round" onclick="save();"><!-- <i class="sqBtnIco_10"></i> -->保存</span>
           				 </div>
                    </form>
                    </div>
                    </div>
	<script>
	
	var crAmtValue ='${crAmt}';
	var currCrAmtValue='${currCrAmt}';
	$("#currCrAmt").text((parseFloat(currCrAmtValue/100)).toFixed(2));
	$("#crAmt").val((parseFloat(crAmtValue/100)).toFixed(2));
		$(function() {
		   setFormatDateValue();
			 var ligerForm = liger.get("prj_lnk_comp_cr_lim_form");
		   $("#prj_lnk_comp_cr_lim_form").ligerForm({
                validate: true
           });
		   
		   $("#prjLnkCompNm").click(function (event){
			   showPrjLnkComp();
		   });
		   
		});
		
		function showPrjLnkComp(){
			var prjLnkCompId = '${crLimit.prjLnkCompId}';
			Add_navTab('tab_prj_lnk_comp_detail' + prjLnkCompId, '挂靠公司详情', '<%=path%>/project/prjlnkcomp/toDetailPage.do?id=' + prjLnkCompId);
		}
		
		//设置日期值
		function setFormatDateValue(){
			var startDt =$("#startDt").val();
			var endDt = $("#endDt").val();
			if(startDt){
		    	var startDate = DateUtils.formatDate(new Date(startDt),DateUtils.YYYY_MM_DD);
		    	$("#startDt").val(startDate);//道路运输许可证有效期
		    }
		    if(endDt){
		    	var endDate = DateUtils.formatDate(new Date(endDt),DateUtils.YYYY_MM_DD);
		    	$("#endDt").val(endDate);//注册日期
		    }
			
		}
		function setPledgorNm(){
			var valid = $("#isLimit")[0].value;
			var flag = $('[name="isLimit"]').prop('checked');
			if(flag){
				if(valid){
				$("#crAmt").val(0);
				if($("#crAmt")){
					  liger.get("crAmt").setDisabled();
				}
				}
			}
		}
		
		   function save(){
			 //frameElement.dialog.disabledBtns();
			  var ligerForm = liger.get("prj_lnk_comp_cr_lim_form");
			 if (!ligerForm.valid()) {
		            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
		            return false; //验证不通过，不执行以下代码
		        }
			        var data = ligerForm.getData();
			        data["compId"] = $("#compId").val();
			        data["id"] = $("#crLimitId").val();
				    data["currCrAmt"] =  (parseFloat(currCrAmtValue/100)).toFixed(2);
			        var url = '<%=path%>/project/prjLnkCompCrLim/add.do';
			        var wait_dialog;
			        $.ajax({
			    		type: 'post',
			    		dataType:'json',
			    		data:data,
			    		url: url,
			    		beforeSend: function(){
					          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
					     },
			    		success:function(msg){
			    			 wait_dialog.close();
			    			 if(msg.success == 1){
			    				 $("#crLimitId").val(msg.data);
			    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
			    			 }else{
			    				 wait_dialog.close();
			    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
			    			 }
			    		}
			    	});
			
		}
	</script>

</body>
</html>